./*
 * name: Mabel Xu
 * date: October 10, 2007
 * filename: TestLinkedList.java
 * description: tests the MyLinkedList class ... calls all methods, outputs results
 */

public class TestLinkedList		// class to test MyLinkedList class
{
	public static void main(String[] args)		// main method ... here will be all things to be tested ...
	{
		// set up MyLinkedList, test for initial conditions
		MyLinkedList list = new MyLinkedList();
		System.out.println("list initialized!");
		System.out.println("size: " + list.size());
		System.out.println("empty? " + list.isEmpty());
		System.out.println();

		// test add() method ... adds 0, 1, 2, 3
		list.add(new Integer(0));
		System.out.println("add 0 to list: \n" + list.toString());
		list.add(new Integer(1));
		System.out.println("add 1 to list: \n" + list.toString());
		list.add(new Integer(2));
		System.out.println("add 2 to list: \n" + list.toString());
		list.add(new Integer(3));
		System.out.println("add 3 to list: \n" + list.toString());

		// test addLast() method ... adds 4, 5, 6 to end
		list.addLast(new Integer(4));
		System.out.println("addLast 4 to list: \n" + list.toString());
		list.addLast(new Integer(5));
		System.out.println("addLast 5 to list: \n" + list.toString());
		list.addLast(new Integer(6));
		System.out.println("addLast 6 to list: \n" + list.toString());

		// test addFirst() method ... adds -3, -2, -1 to beginning
		list.addFirst(new Integer(-1));
		System.out.println("addFirst -1 to list: \n" + list.toString());
		list.addFirst(new Integer(-2));
		System.out.println("addFirst -2 to list: \n" + list.toString());
		list.addFirst(new Integer(-3));
		System.out.println("addFirst -3 to list: \n" + list.toString());
		System.out.println();

		// test set() method ... sets 0 to "zero"
		list.set(3, "zero");
		System.out.println("set index 3 to \"zero\": \n" + list.toString());

		// test getFirst() and getLast() methods ... should return -3 and 6 respectively
		System.out.println("getFirst: " + list.getFirst());
		System.out.println("getLast: " + list.getLast());
		System.out.println();

		// test remove(), removeFirst(), and removeLast() methods ... removes "zero" , then -3, then 6
		list.remove(3);
		System.out.println("remove index 3: \n" + list.toString());
		list.removeFirst();
		System.out.println("removeFirst: \n" + list.toString());
		list.removeLast();
		System.out.println("removeLast: \n" + list.toString());
		System.out.println();

		// test size() and isEmpty() methods
		System.out.println("size: " + list.size());
		System.out.println("empty? " + list.isEmpty());
		System.out.println();
	}		// end of main method (where we test everything)
}		// end of class to test MyLinkedList